package com.fast.cron.db.dao;

import com.fast.cron.db.entry.ExecutionJob;

import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;

/**
 * @author: Leo Jie
 * @date: 2018-10-04 20:03
 * @version: v1.0
 */
public interface ExecutionJobDao {
    /**
     * save the job of execution
     *
     * @param executionJob execution job obj
     * @return row number of result
     * @throws SQLException the error when execute sql
     */
    long saveExecutionJob(ExecutionJob executionJob) throws SQLException;

    /**
     * refresh end time
     *
     * @param executionJobId job id
     * @param endTime        end time
     * @return row number of result
     * @throws SQLException the error when execute sql
     */
    int refreshEndTimeOfExecutionJob(int executionJobId, Timestamp endTime) throws SQLException;


    /**
     * refresh end time
     *
     * @param executionJobId job id
     * @param executionTimes          times of job ran
     * @return row number of result
     * @throws SQLException the error when execute sql
     */
    int refreshRunTimesOfExecutionJob(int executionJobId, int executionTimes) throws SQLException;


    /**
     * refresh end time
     *
     * @param executionJobId job id
     * @param executionStatus         job status of finished
     * @return row number of result
     * @throws SQLException the error when execute sql
     */
    int refreshStatusOfExecutionJob(int executionJobId, int executionStatus) throws SQLException;

    /**
     * list of job
     *
     * @return result of query
     * @throws SQLException the error when execute sql
     */
    List<Map<String, Object>> listJobsOfExecution() throws SQLException;
}
